<!DOCTYPE html>
<html>
<head>
        <title>go-carbon代码测试覆盖率报告</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <style>
                body {
                        background: black;
                        color: rgb(80, 80, 80);
                }
                body, pre, #legend span {
                        font-family: Menlo, monospace;
                        font-weight: bold;
                }
                #topbar {
                        background: black;
                        position: fixed;
                        top: 0; left: 0; right: 0;
                        height: 42px;
                        border-bottom: 1px solid rgb(80, 80, 80);
                }
                #content {
                        margin-top: 50px;
                }
                #nav, #legend {
                        float: left;
                        margin-left: 10px;
                }
                #legend {
                        margin-top: 12px;
                }
                #nav {
                        margin-top: 10px;
                }
                #legend span {
                        margin: 0 5px;
                }
                .cov0 { color: rgb(192, 0, 0) }
                .cov1 { color: rgb(128, 128, 128) }
                .cov2 { color: rgb(116, 140, 131) }
                .cov3 { color: rgb(104, 152, 134) }
                .cov4 { color: rgb(92, 164, 137) }
                .cov5 { color: rgb(80, 176, 140) }
                .cov6 { color: rgb(68, 188, 143) }
                .cov7 { color: rgb(56, 200, 146) }
                .cov8 { color: rgb(44, 212, 149) }
                .cov9 { color: rgb(32, 224, 152) }
                .cov10 { color: rgb(20, 236, 155) }

        </style>
</head>
<body>
<div id="topbar">
        <div id="nav">
                <select id="files"> <option value="file0">github.com/golang-module/carbon/calendar.go (100.0%)</option> <option value="file1">github.com/golang-module/carbon/carbon.go (100.0%)</option> <option value="file2">github.com/golang-module/carbon/database.go (44.4%)</option> <option value="file3">github.com/golang-module/carbon/diffForHumans.go (0.0%)</option> <option value="file4">github.com/golang-module/carbon/final.go (100.0%)</option> <option value="file5">github.com/golang-module/carbon/private.go (100.0%)</option> </select>
        </div>
        <div id="legend">
                <span>not tracked</span>
                <span class="cov0">not covered</span>
                <span class="cov8">covered</span>
        </div>
</div>
<div id="content">
   <pre class="file" id="file0" style="display: block;">package carbon

var (
        // 十二生肖
        SymbolicAnimals = [12]string{&quot;猴&quot;, &quot;鸡&quot;, &quot;狗&quot;, &quot;猪&quot;, &quot;鼠&quot;, &quot;牛&quot;, &quot;虎&quot;, &quot;兔&quot;, &quot;龙&quot;, &quot;蛇&quot;, &quot;马&quot;, &quot;羊&quot;}

        // 天干
        HeavenlyStems = [10]string{&quot;庚&quot;, &quot;辛&quot;, &quot;壬&quot;, &quot;癸&quot;, &quot;甲&quot;, &quot;乙&quot;, &quot;丙&quot;, &quot;丙&quot;, &quot;戊&quot;, &quot;己&quot;}

        // 地支
        EarthlyBranches = [12]string{&quot;申&quot;, &quot;酉&quot;, &quot;戌&quot;, &quot;亥&quot;, &quot;子&quot;, &quot;丑&quot;, &quot;寅&quot;, &quot;卯&quot;, &quot;辰&quot;, &quot;巳&quot;, &quot;午&quot;, &quot;未&quot;}
)

// ToAnimalYear 获取生肖年
func (c Carbon) ToAnimalYear() string <span class="cov8" title="1">{
        if c.Time.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">year := c.Time.Year()
        return SymbolicAnimals[year%12]</span>
}

// ToLunarYear 获取农历年
func (c Carbon) ToLunarYear() string <span class="cov8" title="1">{
        if c.Time.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">year := c.Time.Year()
        return HeavenlyStems[year%10] + EarthlyBranches[year%12]</span>
}

// IsYearOfRat 是否是鼠年
func (c Carbon) IsYearOfRat() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 4 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfOx 是否是牛年
func (c Carbon) IsYearOfOx() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 5 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfTiger 是否是虎年
func (c Carbon) IsYearOfTiger() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 6 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfRabbit 是否是兔年
func (c Carbon) IsYearOfRabbit() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 7 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfDragon 是否是龙年
func (c Carbon) IsYearOfDragon() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 8 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfSnake 是否是蛇年
func (c Carbon) IsYearOfSnake() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 9 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfHorse 是否是马年
func (c Carbon) IsYearOfHorse() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 10 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfGoat 是否是羊年
func (c Carbon) IsYearOfGoat() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 11 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfMonkey 是否是猴年
func (c Carbon) IsYearOfMonkey() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 0 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfRooster 是否是鸡年
func (c Carbon) IsYearOfRooster() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 1 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfDog 是否是狗年
func (c Carbon) IsYearOfDog() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 2 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsYearOfPig 是否是猪年
func (c Carbon) IsYearOfPig() bool <span class="cov8" title="1">{
        year := c.Time.Year()
        if year%12 == 3 </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}
</pre>
        <pre class="file" id="file1" style="display: none">package carbon

import (
        &quot;strconv&quot;
        &quot;strings&quot;
        &quot;time&quot;
)

type Carbon struct {
        Time  time.Time
        Loc   *time.Location
        Error error
}

// Now 当前
func (c Carbon) Now() Carbon <span class="cov8" title="1">{
        c.Time = time.Now()
        return c
}</span>

// Now 当前(默认时区)
func Now() Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).Now()
}</span>

// Tomorrow 明天
func (c Carbon) Tomorrow() Carbon <span class="cov8" title="1">{
        if c.Time.IsZero() </span><span class="cov8" title="1">{
                c.Time = time.Now().AddDate(0, 0, 1)
        }</span> else<span class="cov8" title="1"> {
                c.Time = c.Time.AddDate(0, 0, 1)
        }</span>
        <span class="cov8" title="1">return c</span>
}

// Tomorrow 明天(默认时区)
func Tomorrow() Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).Tomorrow()
}</span>

// Yesterday 昨天
func (c Carbon) Yesterday() Carbon <span class="cov8" title="1">{
        if c.Time.IsZero() </span><span class="cov8" title="1">{
                c.Time = time.Now().AddDate(0, 0, -1)
        }</span> else<span class="cov8" title="1"> {
                c.Time = c.Time.AddDate(0, 0, -1)
        }</span>
        <span class="cov8" title="1">return c</span>
}

// Yesterday 昨天(默认时区)
func Yesterday() Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).Yesterday()
}</span>

// CreateFromTimestamp 从时间戳创建Carbon实例
func (c Carbon) CreateFromTimestamp(timestamp int64) Carbon <span class="cov8" title="1">{
        ts := timestamp
        switch len(strconv.FormatInt(timestamp, 10)) </span>{
        case 10:<span class="cov8" title="1">
                ts = timestamp</span>
        case 13:<span class="cov8" title="1">
                ts = timestamp / 1e3</span>
        case 16:<span class="cov8" title="1">
                ts = timestamp / 1e6</span>
        case 19:<span class="cov8" title="1">
                ts = timestamp / 1e9</span>
        default:<span class="cov8" title="1">
                ts = 0</span>
        }
        <span class="cov8" title="1">c.Time = time.Unix(ts, 0)
        return c</span>
}

// CreateFromTimestamp 从时间戳创建Carbon实例(默认时区)
func CreateFromTimestamp(timestamp int64) Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).CreateFromTimestamp(timestamp)
}</span>

// CreateFromDateTime 从年月日时分秒创建Carbon实例
func (c Carbon) CreateFromDateTime(year int, month int, day int, hour int, minute int, second int) Carbon <span class="cov8" title="1">{
        c.Time = time.Date(year, time.Month(month), day, hour, minute, second, 0, c.Loc)
        return c
}</span>

// CreateFromDateTime 从年月日时分秒创建Carbon实例(默认时区)
func CreateFromDateTime(year int, month int, day int, hour int, minute int, second int) Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).CreateFromDateTime(year, month, day, hour, minute, second)
}</span>

// CreateFromDate 从年月日创建Carbon实例
func (c Carbon) CreateFromDate(year int, month int, day int) Carbon <span class="cov8" title="1">{
        hour, minute, second := time.Now().Clock()
        c.Time = time.Date(year, time.Month(month), day, hour, minute, second, 0, c.Loc)
        return c
}</span>

// CreateFromDate 从年月日创建Carbon实例(默认时区)
func CreateFromDate(year int, month int, day int) Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).CreateFromDate(year, month, day)
}</span>

// CreateFromTime 从时分秒创建Carbon实例
func (c Carbon) CreateFromTime(hour int, minute int, second int) Carbon <span class="cov8" title="1">{
        year, month, day := time.Now().Date()
        c.Time = time.Date(year, month, day, hour, minute, second, 0, c.Loc)
        return c
}</span>

// CreateFromTime 从时分秒创建Carbon实例(默认时区)
func CreateFromTime(hour int, minute int, second int) Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).CreateFromTime(hour, minute, second)
}</span>

// Time2Carbon 原生time.Time 转换成 Carbon实例
func Time2Carbon(tt time.Time) Carbon <span class="cov8" title="1">{
        loc, _ := time.LoadLocation(Local)
        return Carbon{Time: tt, Loc: loc}
}</span>

// Carbon2Time Carbon实例 转换成 原生time.Time
func (c Carbon) Carbon2Time() time.Time <span class="cov8" title="1">{
        return c.Time
}</span>

// Parse 解析标准格式时间字符串
func (c Carbon) Parse(value string) Carbon <span class="cov8" title="1">{
        if c.Error != nil </span><span class="cov8" title="1">{
                return c
        }</span>

        <span class="cov8" title="1">layout := DateTimeFormat

        if value == &quot;&quot; || value == &quot;0&quot; || value == &quot;0000-00-00 00:00:00&quot; || value == &quot;0000-00-00&quot; || value == &quot;00:00:00&quot; </span><span class="cov8" title="1">{
                return c
        }</span>

        <span class="cov8" title="1">if len(value) == 10 &amp;&amp; strings.Count(value, &quot;-&quot;) == 2 </span><span class="cov8" title="1">{
                layout = DateFormat
        }</span>

        <span class="cov8" title="1">if strings.Index(value, &quot;T&quot;) == 10 </span><span class="cov8" title="1">{
                layout = RFC3339Format
        }</span>

        <span class="cov8" title="1">if _, err := strconv.ParseInt(value, 10, 64); err == nil </span><span class="cov8" title="1">{
                switch len(value) </span>{
                case 8:<span class="cov8" title="1">
                        layout = ShortDateFormat</span>
                case 14:<span class="cov8" title="1">
                        layout = ShortDateTimeFormat</span>
                }
        }

        <span class="cov8" title="1">tt, err := parseByLayout(value, layout)
        c.Time = tt
        c.Error = err
        return c</span>
}

// Parse 解析标准格式时间字符串(默认时区)
func Parse(value string) Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).Parse(value)
}</span>

// ParseByFormat 解析指定格式时间字符串
func (c Carbon) ParseByFormat(value string, format string) Carbon <span class="cov8" title="1">{
        if c.Error != nil </span><span class="cov8" title="1">{
                return c
        }</span>
        <span class="cov8" title="1">layout := format2layout(format)
        return c.ParseByLayout(value, layout)</span>
}

// ParseByFormat 解析指定格式时间字符串(默认时区)
func ParseByFormat(value string, format string) Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).ParseByFormat(value, format)
}</span>

// ParseByLayout 解析布局字符串
func (c Carbon) ParseByLayout(value string, layout string) Carbon <span class="cov8" title="1">{
        if c.Error != nil </span><span class="cov8" title="1">{
                return c
        }</span>
        <span class="cov8" title="1">tt, err := parseByLayout(value, layout)
        c.Time = tt
        c.Error = err
        return c</span>
}

// ParseByLayout 解析布局字符串(默认时区)
func ParseByLayout(value string, layout string) Carbon <span class="cov8" title="1">{
        return SetTimezone(Local).ParseByLayout(value, layout)
}</span>

// AddDurations 按照持续时间字符串增加时间
// 支持整数/浮点数和符号ns(纳秒)、us(微妙)、ms(毫秒)、s(秒)、m(分钟)、h(小时)的组合
func (c Carbon) AddDuration(duration string) Carbon <span class="cov8" title="1">{
        if c.Error != nil </span><span class="cov8" title="1">{
                return c
        }</span>
        <span class="cov8" title="1">td, err := parseByDuration(duration)
        c.Time = c.Time.Add(td)
        c.Error = err
        return c</span>
}

// SubDurations 按照持续时间字符串减少时间
// 支持整数/浮点数和符号ns(纳秒)、us(微妙)、ms(毫秒)、s(秒)、m(分钟)、h(小时)的组合
func (c Carbon) SubDuration(duration string) Carbon <span class="cov8" title="1">{
        if c.Error != nil </span><span class="cov8" title="1">{
                return c
        }</span>
        <span class="cov8" title="1">td, err := parseByDuration(&quot;-&quot; + duration)
        c.Time = c.Time.Add(td)
        c.Error = err
        return c</span>
}

// AddCenturies N世纪后
func (c Carbon) AddCenturies(centuries int) Carbon <span class="cov8" title="1">{
        return c.AddYears(YearsPerCentury * centuries)
}</span>

// AddCenturiesNoOverflow N世纪后(月份不溢出)
func (c Carbon) AddCenturiesNoOverflow(centuries int) Carbon <span class="cov8" title="1">{
        return c.AddYearsNoOverflow(centuries * YearsPerCentury)
}</span>

// AddCentury 1世纪后
func (c Carbon) AddCentury() Carbon <span class="cov8" title="1">{
        return c.AddCenturies(1)
}</span>

// AddCenturyNoOverflow 1世纪后(月份不溢出)
func (c Carbon) AddCenturyNoOverflow() Carbon <span class="cov8" title="1">{
        return c.AddCenturiesNoOverflow(1)
}</span>

// SubCenturies N世纪前
func (c Carbon) SubCenturies(centuries int) Carbon <span class="cov8" title="1">{
        return c.SubYears(YearsPerCentury * centuries)
}</span>

// SubCenturiesNoOverflow N世纪前(月份不溢出)
func (c Carbon) SubCenturiesNoOverflow(centuries int) Carbon <span class="cov8" title="1">{
        return c.SubYearsNoOverflow(centuries * YearsPerCentury)
}</span>

// SubCentury 1世纪前
func (c Carbon) SubCentury() Carbon <span class="cov8" title="1">{
        return c.SubCenturies(1)
}</span>

// SubCenturyNoOverflow 1世纪前(月份不溢出)
func (c Carbon) SubCenturyNoOverflow() Carbon <span class="cov8" title="1">{
        return c.SubCenturiesNoOverflow(1)
}</span>

// AddYears N年后
func (c Carbon) AddYears(years int) Carbon <span class="cov8" title="1">{
        c.Time = c.Time.AddDate(years, 0, 0)
        return c
}</span>

// AddYearsNoOverflow N年后(月份不溢出)
func (c Carbon) AddYearsNoOverflow(years int) Carbon <span class="cov8" title="1">{
        year := c.Time.Year() + years
        month := c.Time.Month()
        day := c.Time.Day()

        // 获取N年后本月的最后一天
        last := time.Date(year, month, 1, c.Time.Hour(), c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc).AddDate(0, 1, -1)

        if day &gt; last.Day() </span><span class="cov8" title="1">{
                day = last.Day()
        }</span>

        <span class="cov8" title="1">c.Time = time.Date(last.Year(), last.Month(), day, c.Time.Hour(), c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc)
        return c</span>
}

// AddYear 1年后
func (c Carbon) AddYear() Carbon <span class="cov8" title="1">{
        return c.AddYears(1)
}</span>

// AddYearNoOverflow 1年后(月份不溢出)
func (c Carbon) AddYearNoOverflow() Carbon <span class="cov8" title="1">{
        return c.AddYearsNoOverflow(1)
}</span>

// SubYears N年前
func (c Carbon) SubYears(years int) Carbon <span class="cov8" title="1">{
        c.Time = c.Time.AddDate(-years, 0, 0)
        return c
}</span>

// SubYearsWithOverflow N年前(月份不溢出)
func (c Carbon) SubYearsNoOverflow(years int) Carbon <span class="cov8" title="1">{
        return c.AddYearsNoOverflow(-years)
}</span>

// SubYear 1年前
func (c Carbon) SubYear() Carbon <span class="cov8" title="1">{
        return c.SubYears(1)
}</span>

// SubYearWithOverflow 1年前(月份不溢出)
func (c Carbon) SubYearNoOverflow() Carbon <span class="cov8" title="1">{
        return c.SubYearsNoOverflow(1)
}</span>

// AddQuarters N季度后
func (c Carbon) AddQuarters(quarters int) Carbon <span class="cov8" title="1">{
        return c.AddMonths(quarters * MonthsPerQuarter)
}</span>

// AddQuartersNoOverflow N季度后(月份不溢出)
func (c Carbon) AddQuartersNoOverflow(quarters int) Carbon <span class="cov8" title="1">{
        return c.AddMonthsNoOverflow(quarters * MonthsPerQuarter)
}</span>

// AddQuarter 1季度后
func (c Carbon) AddQuarter() Carbon <span class="cov8" title="1">{
        return c.AddQuarters(1)
}</span>

// NextQuarters 1季度后(月份不溢出)
func (c Carbon) AddQuarterNoOverflow() Carbon <span class="cov8" title="1">{
        return c.AddQuartersNoOverflow(1)
}</span>

// SubQuarters N季度前
func (c Carbon) SubQuarters(quarters int) Carbon <span class="cov8" title="1">{
        return c.SubMonths(quarters * MonthsPerQuarter)
}</span>

// SubQuartersNoOverflow N季度前(月份不溢出)
func (c Carbon) SubQuartersNoOverflow(quarters int) Carbon <span class="cov8" title="1">{
        return c.AddMonthsNoOverflow(-quarters * MonthsPerQuarter)
}</span>

// SubQuarter 1季度前
func (c Carbon) SubQuarter() Carbon <span class="cov8" title="1">{
        return c.SubQuarters(1)
}</span>

// SubQuarterNoOverflow 1季度前(月份不溢出)
func (c Carbon) SubQuarterNoOverflow() Carbon <span class="cov8" title="1">{
        return c.SubQuartersNoOverflow(1)
}</span>

// AddMonths N月后
func (c Carbon) AddMonths(months int) Carbon <span class="cov8" title="1">{
        c.Time = c.Time.AddDate(0, months, 0)
        return c
}</span>

// AddMonthsNoOverflow N月后(月份不溢出)
func (c Carbon) AddMonthsNoOverflow(months int) Carbon <span class="cov8" title="1">{
        year := c.Time.Year()
        month := c.Time.Month() + time.Month(months)
        day := c.Time.Day()

        // 获取N月后的最后一天
        last := time.Date(year, month, 1, c.Time.Hour(), c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc).AddDate(0, 1, -1)

        if day &gt; last.Day() </span><span class="cov8" title="1">{
                day = last.Day()
        }</span>

        <span class="cov8" title="1">c.Time = time.Date(last.Year(), last.Month(), day, c.Time.Hour(), c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc)
        return c</span>
}

// AddMonth 1月后
func (c Carbon) AddMonth() Carbon <span class="cov8" title="1">{
        return c.AddMonths(1)
}</span>

// AddMonthNoOverflow 1月后(月份不溢出)
func (c Carbon) AddMonthNoOverflow() Carbon <span class="cov8" title="1">{
        return c.AddMonthsNoOverflow(1)
}</span>

// SubMonths N月前
func (c Carbon) SubMonths(months int) Carbon <span class="cov8" title="1">{
        c.Time = c.Time.AddDate(0, -months, 0)
        return c
}</span>

// SubMonthsNoOverflow N月前(月份不溢出)
func (c Carbon) SubMonthsNoOverflow(months int) Carbon <span class="cov8" title="1">{
        return c.AddMonthsNoOverflow(-months)
}</span>

// SubMonth 1月前
func (c Carbon) SubMonth() Carbon <span class="cov8" title="1">{
        return c.SubMonths(1)
}</span>

// SubMonthNoOverflow 1月前(月份不溢出)
func (c Carbon) SubMonthNoOverflow() Carbon <span class="cov8" title="1">{
        return c.SubMonthsNoOverflow(1)
}</span>

// AddWeeks N周后
func (c Carbon) AddWeeks(weeks int) Carbon <span class="cov8" title="1">{
        return c.AddDays(weeks * DaysPerWeek)
}</span>

// AddWeek 1天后
func (c Carbon) AddWeek() Carbon <span class="cov8" title="1">{
        return c.AddWeeks(1)
}</span>

// SubWeeks N周后
func (c Carbon) SubWeeks(weeks int) Carbon <span class="cov8" title="1">{
        return c.SubDays(weeks * DaysPerWeek)
}</span>

// SubWeek 1天后
func (c Carbon) SubWeek() Carbon <span class="cov8" title="1">{
        return c.SubWeeks(1)
}</span>

// AddDays N天后
func (c Carbon) AddDays(days int) Carbon <span class="cov8" title="1">{
        c.Time = c.Time.AddDate(0, 0, days)
        return c
}</span>

// AddDay 1天后
func (c Carbon) AddDay() Carbon <span class="cov8" title="1">{
        return c.AddDays(1)
}</span>

// SubDays N天前
func (c Carbon) SubDays(days int) Carbon <span class="cov8" title="1">{
        c.Time = c.Time.AddDate(0, 0, -days)
        return c
}</span>

// SubDay 1天前
func (c Carbon) SubDay() Carbon <span class="cov8" title="1">{
        return c.SubDays(1)
}</span>

// AddHours N小时后
func (c Carbon) AddHours(hours int) Carbon <span class="cov8" title="1">{
        td := time.Duration(hours) * time.Hour
        c.Time = c.Time.Add(td)
        return c
}</span>

// AddHour 1小时后
func (c Carbon) AddHour() Carbon <span class="cov8" title="1">{
        return c.AddHours(1)
}</span>

// SubHours N小时前
func (c Carbon) SubHours(hours int) Carbon <span class="cov8" title="1">{
        td := time.Duration(hours) * -time.Hour
        c.Time = c.Time.Add(td)
        return c
}</span>

// SubHour 1小时前
func (c Carbon) SubHour() Carbon <span class="cov8" title="1">{
        return c.SubHours(1)
}</span>

// AddMinutes N分钟后
func (c Carbon) AddMinutes(minutes int) Carbon <span class="cov8" title="1">{
        td := time.Duration(minutes) * time.Minute
        c.Time = c.Time.Add(td)
        return c
}</span>

// AddMinute 1分钟后
func (c Carbon) AddMinute() Carbon <span class="cov8" title="1">{
        return c.AddMinutes(1)
}</span>

// SubMinutes N分钟前
func (c Carbon) SubMinutes(minutes int) Carbon <span class="cov8" title="1">{
        td := time.Duration(minutes) * -time.Minute
        c.Time = c.Time.Add(td)
        return c
}</span>

// SubMinute 1分钟前
func (c Carbon) SubMinute() Carbon <span class="cov8" title="1">{
        return c.SubMinutes(1)
}</span>

// AddSeconds N秒钟后
func (c Carbon) AddSeconds(seconds int) Carbon <span class="cov8" title="1">{
        td := time.Duration(seconds) * time.Second
        c.Time = c.Time.Add(td)
        return c
}</span>

// AddSecond 1秒钟后
func (c Carbon) AddSecond() Carbon <span class="cov8" title="1">{
        return c.AddSeconds(1)
}</span>

// SubSeconds N秒钟前
func (c Carbon) SubSeconds(seconds int) Carbon <span class="cov8" title="1">{
        td := time.Duration(seconds) * -time.Second
        c.Time = c.Time.Add(td)
        return c
}</span>

// SubSecond 1秒钟前
func (c Carbon) SubSecond() Carbon <span class="cov8" title="1">{
        return c.SubSeconds(1)
}</span>

// StartOfYear 本年开始时间
func (c Carbon) StartOfYear() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), 1, 1, 0, 0, 0, 0, c.Loc)
        return c
}</span>

// EndOfYear 本年结束时间
func (c Carbon) EndOfYear() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), 12, 31, 23, 59, 59, 0, c.Loc)
        return c
}</span>

// StartOfMonth 本月开始时间
func (c Carbon) StartOfMonth() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), 1, 0, 0, 0, 0, c.Loc)
        return c
}</span>

// EndOfMonth 本月结束时间
func (c Carbon) EndOfMonth() Carbon <span class="cov8" title="1">{
        t := time.Date(c.Time.Year(), c.Time.Month(), 1, 23, 59, 59, 0, c.Loc)
        c.Time = t.AddDate(0, 1, -1)
        return c
}</span>

// StartOfWeek 本周开始时间
func (c Carbon) StartOfWeek() Carbon <span class="cov8" title="1">{
        days := c.Time.Weekday()
        if days == 0 </span><span class="cov8" title="1">{
                days = DaysPerWeek
        }</span>
        <span class="cov8" title="1">t := time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), 0, 0, 0, 0, c.Loc)
        c.Time = t.AddDate(0, 0, int(1-days))
        return c</span>
}

// EndOfWeek 本周结束时间
func (c Carbon) EndOfWeek() Carbon <span class="cov8" title="1">{
        days := c.Time.Weekday()
        if days == 0 </span><span class="cov8" title="1">{
                days = DaysPerWeek
        }</span>
        <span class="cov8" title="1">t := time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), 23, 59, 59, 0, c.Loc)
        c.Time = t.AddDate(0, 0, int(DaysPerWeek-days))
        return c</span>
}

// StartOfDay 本日开始时间
func (c Carbon) StartOfDay() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), 0, 0, 0, 0, c.Loc)
        return c
}</span>

// EndOfDay 本日结束时间
func (c Carbon) EndOfDay() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), 23, 59, 59, 0, c.Loc)
        return c
}</span>

// StartOfHour 小时开始时间
func (c Carbon) StartOfHour() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), c.Time.Hour(), 0, 0, 0, c.Loc)
        return c
}</span>

// EndOfHour 小时结束时间
func (c Carbon) EndOfHour() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), c.Time.Hour(), 59, 59, 0, c.Loc)
        return c
}</span>

// StartOfMinute 分钟开始时间
func (c Carbon) StartOfMinute() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), c.Time.Hour(), c.Time.Minute(), 0, 0, c.Loc)
        return c
}</span>

// EndOfMinute 分钟结束时间
func (c Carbon) EndOfMinute() Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), c.Time.Hour(), c.Time.Minute(), 59, 0, c.Loc)
        return c
}</span>

// Timezone 设置时区
func SetTimezone(name string) Carbon <span class="cov8" title="1">{
        loc, err := getLocationByTimezone(name)
        return Carbon{Loc: loc, Error: err}
}</span>

// Timezone 设置时区
func (c Carbon) SetTimezone(name string) Carbon <span class="cov8" title="1">{
        loc, err := getLocationByTimezone(name)
        c.Loc = loc
        c.Error = err
        return c
}</span>

// SetYear 设置年
func (c Carbon) SetYear(year int) Carbon <span class="cov8" title="1">{
        c.Time = time.Date(year, c.Time.Month(), c.Time.Day(), c.Time.Hour(), c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc)
        return c
}</span>

// SetMonth 设置月
func (c Carbon) SetMonth(month int) Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), time.Month(month), c.Time.Day(), c.Time.Hour(), c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc)
        return c
}</span>

// SetDay 设置日
func (c Carbon) SetDay(day int) Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), day, c.Time.Hour(), c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc)
        return c
}</span>

// SetHour 设置时
func (c Carbon) SetHour(hour int) Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), hour, c.Time.Minute(), c.Time.Second(), c.Time.Nanosecond(), c.Loc)
        return c
}</span>

// SetMinute 设置分
func (c Carbon) SetMinute(minute int) Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), c.Time.Hour(), minute, c.Time.Second(), c.Time.Nanosecond(), c.Loc)
        return c
}</span>

// SetSecond 设置秒
func (c Carbon) SetSecond(second int) Carbon <span class="cov8" title="1">{
        c.Time = time.Date(c.Time.Year(), c.Time.Month(), c.Time.Day(), c.Time.Hour(), c.Time.Minute(), second, c.Time.Nanosecond(), c.Loc)
        return c
}</span>
</pre>
        <pre class="file" id="file2" style="display: none">package carbon

import (
        &quot;database/sql/driver&quot;
        &quot;fmt&quot;
        &quot;time&quot;
)

type ToDateTimeString struct {
        Carbon
}

type ToDateString struct {
        Carbon
}

type ToTimeString struct {
        Carbon
}

type ToTimestamp struct {
        Carbon
}

type ToTimestampWithSecond struct {
        Carbon
}

type ToTimestampWithMillisecond struct {
        Carbon
}

type ToTimestampWithMicrosecond struct {
        Carbon
}

type ToTimestampWithNanosecond struct {
        Carbon
}

func (c *Carbon) Scan(v interface{}) error <span class="cov0" title="0">{
        value, ok := v.(time.Time)
        if ok </span><span class="cov0" title="0">{
                *c = Carbon{Time: value}
                return nil
        }</span>
        <span class="cov0" title="0">return fmt.Errorf(&quot;can not convert %v to timestamp&quot;, v)</span>
}

func (c Carbon) Value() (driver.Value, error) <span class="cov0" title="0">{
        var zeroTime time.Time
        var timeTime = c.Time
        if timeTime.UnixNano() == zeroTime.UnixNano() </span><span class="cov0" title="0">{
                return nil, nil
        }</span>
        <span class="cov0" title="0">return timeTime, nil</span>
}

func (c ToDateTimeString) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`&quot;%s&quot;`, c.ToDateTimeString())), nil
}</span>

func (c ToDateString) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`&quot;%s&quot;`, c.ToDateString())), nil
}</span>

func (c ToTimeString) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`&quot;%s&quot;`, c.ToTimeString())), nil
}</span>

func (c ToTimestamp) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`%d`, c.ToTimestamp())), nil
}</span>

func (c ToTimestampWithSecond) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`%d`, c.ToTimestampWithSecond())), nil
}</span>

func (c ToTimestampWithMillisecond) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`%d`, c.ToTimestampWithMillisecond())), nil
}</span>

func (c ToTimestampWithMicrosecond) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`%d`, c.ToTimestampWithMicrosecond())), nil
}</span>

func (c ToTimestampWithNanosecond) MarshalJSON() ([]byte, error) <span class="cov8" title="1">{
        return []byte(fmt.Sprintf(`%d`, c.ToTimestampWithNanosecond())), nil
}</span>
</pre>
        <pre class="file" id="file3" style="display: none">package carbon

import (
        &quot;fmt&quot;
        &quot;math&quot;
        &quot;strconv&quot;
)

func (c Carbon) DiffForHumans() string <span class="cov0" title="0">{
        fmt.Println(c.DiffInDays(Now()))
        flag := &quot;&quot;
        if c.DiffInSeconds(Now()) &gt; 0 </span><span class="cov0" title="0">{
                flag = &quot;前&quot;
        }</span> else<span class="cov0" title="0"> {
                flag = &quot;后&quot;
        }</span>
        <span class="cov0" title="0">dc := (c.ToTimestamp() - Now().ToTimestamp()) / 31536000

        if math.Abs(float64(dc)) &gt;= 1 </span><span class="cov0" title="0">{
                return strconv.FormatInt(dc, 10) + &quot; 年&quot; + flag
        }</span>

        <span class="cov0" title="0">mc := (c.ToTimestamp() - Now().ToTimestamp()) / 604800

        if math.Abs(float64(mc)) &gt;= 1 </span><span class="cov0" title="0">{
                return strconv.FormatInt(mc, 10) + &quot; 周&quot; + flag
        }</span>
        <span class="cov0" title="0">return &quot;&quot;</span>
}

func (c Carbon) DiffForHumansFrom(end Carbon) string <span class="cov0" title="0">{
        return c.Time.In(c.Loc).String()
}</span>
</pre>
        <pre class="file" id="file4" style="display: none">package carbon

import (
        &quot;bytes&quot;
        &quot;strconv&quot;
        &quot;strings&quot;
        &quot;time&quot;
)

// ToString 输出&quot;2006-01-02 15:04:05.999999999 -0700 MST&quot;格式字符串
func (c Carbon) ToString() string <span class="cov8" title="1">{
        return c.Time.In(c.Loc).String()
}</span>

// ToTimestamp ToTimestampWithSecond的简称
func (c Carbon) ToTimestamp() int64 <span class="cov8" title="1">{
        return c.ToTimestampWithSecond()
}</span>

// ToTimestampWithSecond 输出秒级时间戳
func (c Carbon) ToTimestampWithSecond() int64 <span class="cov8" title="1">{
        return c.Time.Unix()
}</span>

// ToTimestampWithMillisecond 输出毫秒级时间戳
func (c Carbon) ToTimestampWithMillisecond() int64 <span class="cov8" title="1">{
        return c.Time.UnixNano() / int64(time.Millisecond)
}</span>

// ToTimestampWithMicrosecond 输出微秒级时间戳
func (c Carbon) ToTimestampWithMicrosecond() int64 <span class="cov8" title="1">{
        return c.Time.UnixNano() / int64(time.Microsecond)
}</span>

// ToTimestampWithNanosecond 输出纳秒级时间戳
func (c Carbon) ToTimestampWithNanosecond() int64 <span class="cov8" title="1">{
        return c.Time.UnixNano()
}</span>

// Format ToFormatString的简称
func (c Carbon) Format(format string) string <span class="cov8" title="1">{
        return c.ToFormatString(format)
}</span>

// ToFormatString 输出指定格式时间
func (c Carbon) ToFormatString(format string) string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>

        <span class="cov8" title="1">runes := []rune(format)
        buffer := bytes.NewBuffer(nil)
        for i := 0; i &lt; len(runes); i++ </span><span class="cov8" title="1">{
                if layout, ok := formats[byte(runes[i])]; ok </span><span class="cov8" title="1">{
                        buffer.WriteString(c.Time.In(c.Loc).Format(layout))
                }</span> else<span class="cov8" title="1"> {
                        switch runes[i] </span>{
                        case '\\':<span class="cov8" title="1">
                                buffer.WriteRune(runes[i+1])
                                i += 2
                                continue</span>
                        case 'W':<span class="cov8" title="1"> // ISO-8601 格式数字表示的年份中的第几周，取值范围 1-52
                                buffer.WriteString(strconv.Itoa(c.WeekOfYear()))</span>
                        case 'N':<span class="cov8" title="1"> // ISO-8601 格式数字表示的星期中的第几天，取值范围 1-7
                                buffer.WriteString(strconv.Itoa(c.DayOfWeek()))</span>
                        case 'S':<span class="cov8" title="1"> // 第几天的英文缩写后缀，如st, nd, rd, th
                                day := c.Time.In(c.Loc).Format(&quot;02&quot;)
                                suffix := &quot;&quot;
                                switch day </span>{
                                case &quot;01&quot;, &quot;21&quot;, &quot;31&quot;:<span class="cov8" title="1">
                                        suffix = &quot;st&quot;</span>
                                case &quot;02&quot;, &quot;22&quot;:<span class="cov8" title="1">
                                        suffix = &quot;nd&quot;</span>
                                case &quot;03&quot;, &quot;23&quot;:<span class="cov8" title="1">
                                        suffix = &quot;rd&quot;</span>
                                default:<span class="cov8" title="1">
                                        suffix = &quot;th&quot;</span>
                                }
                                <span class="cov8" title="1">buffer.WriteString(suffix)</span>
                        case 'L':<span class="cov8" title="1"> // 是否为闰年，如果是闰年为 1，否则为 0
                                if c.IsLeapYear() </span><span class="cov8" title="1">{
                                        buffer.WriteString(&quot;1&quot;)
                                }</span> else<span class="cov8" title="1"> {
                                        buffer.WriteString(&quot;0&quot;)
                                }</span>
                        case 'G':<span class="cov8" title="1"> // 数字表示的小时，24 小时格式，没有前导零，取值范围 0-23
                                s := strings.Replace(c.Time.In(c.Loc).Format(&quot;15&quot;), &quot;0&quot;, &quot;&quot;, 1)
                                buffer.WriteString(s)</span>
                        case 'U':<span class="cov8" title="1"> // 秒级时间戳，如 1611818268
                                buffer.WriteString(strconv.FormatInt(c.ToTimestamp(), 10))</span>
                        case 'u':<span class="cov8" title="1"> // 数字表示的毫秒，如 999
                                buffer.WriteString(strconv.Itoa(c.Millisecond()))</span>
                        case 'w':<span class="cov8" title="1"> // 数字表示的星期中的第几天，取值范围 0-6
                                buffer.WriteString(strconv.Itoa(c.DayOfWeek() - 1))</span>
                        case 't':<span class="cov8" title="1"> // 指定的月份有几天，取值范围 28-31
                                buffer.WriteString(strconv.Itoa(c.DaysInMonth()))</span>
                        case 'z':<span class="cov8" title="1"> // 年份中的第几天，取值范围 0-365
                                buffer.WriteString(strconv.Itoa(c.DayOfYear() - 1))</span>
                        case 'e':<span class="cov8" title="1"> // 当前时区，如 UTC，GMT，Atlantic/Azores
                                buffer.WriteString(c.Timezone())</span>
                        default:<span class="cov8" title="1">
                                buffer.WriteRune(runes[i])</span>
                        }
                }
        }
        <span class="cov8" title="1">return buffer.String()</span>
}

// ToDayDateTimeString 输出天数日期时间字符串
func (c Carbon) ToDayDateTimeString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(DayDateTimeFormat)</span>
}

// ToDateTimeString 输出日期时间字符串
func (c Carbon) ToDateTimeString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(DateTimeFormat)</span>
}

// ToDateString 输出日期字符串
func (c Carbon) ToDateString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(DateFormat)</span>
}

// ToTimeString 输出时间字符串
func (c Carbon) ToTimeString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(TimeFormat)</span>
}

// ToAtomString 输出Atom格式字符串
func (c Carbon) ToAtomString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC3339Format)</span>
}

// ToAnsicString 输出Ansic格式字符串
func (c Carbon) ToAnsicString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(AnsicFormat)</span>
}

// ToCookieString 输出Cookie格式字符串
func (c Carbon) ToCookieString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(CookieFormat)</span>
}

// ToRssString 输出RSS格式字符串
func (c Carbon) ToRssString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RssFormat)</span>
}

// ToW3cString 输出W3C格式字符串
func (c Carbon) ToW3cString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC3339Format)</span>
}

// ToUnixDateString 输出UnixDate格式字符串
func (c Carbon) ToUnixDateString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(UnixDateFormat)</span>
}

// ToUnixDateString 输出RubyDate格式字符串
func (c Carbon) ToRubyDateString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RubyDateFormat)</span>
}

// ToKitchenString 输出Kitchen格式字符串
func (c Carbon) ToKitchenString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(KitchenFormat)</span>
}

// ToRfc822String 输出RFC822格式字符串
func (c Carbon) ToRfc822String() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC822Format)</span>
}

// ToRfc822zString 输出RFC822Z格式字符串
func (c Carbon) ToRfc822zString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC822ZFormat)</span>
}

// ToRfc850String 输出RFC850格式字符串
func (c Carbon) ToRfc850String() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC850Format)</span>
}

// ToRfc1036String 输出RFC1036格式字符串
func (c Carbon) ToRfc1036String() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC1036Format)</span>
}

// ToRfc1123String 输出RFC1123格式字符串
func (c Carbon) ToRfc1123String() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC1123Format)</span>
}

// ToRfc1123ZString 输出RFC1123Z格式字符串
func (c Carbon) ToRfc1123ZString() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC1123ZFormat)</span>
}

// ToRfc2822String 输出RFC2822格式字符串
func (c Carbon) ToRfc2822String() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC2822Format)</span>
}

// ToRfc3339String 输出RFC3339格式字符串
func (c Carbon) ToRfc3339String() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC3339Format)</span>
}

// ToRfc7231String 输出RFC7231格式字符串
func (c Carbon) ToRfc7231String() string <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return &quot;&quot;
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Format(RFC7231Format)</span>
}

// DiffInWeeks 相差多少周
func (start Carbon) DiffInWeeks(end Carbon) int64 <span class="cov8" title="1">{
        return start.DiffInSeconds(end) / SecondsPerWeek
}</span>

// DiffInWeeksWithAbs 相差多少周（绝对值）
func (start Carbon) DiffInWeeksWithAbs(end Carbon) int64 <span class="cov8" title="1">{
        diff := start.DiffInWeeks(end)
        if diff &lt; 0 </span><span class="cov8" title="1">{
                diff = -diff
        }</span>
        <span class="cov8" title="1">return diff</span>
}

// DiffInDays 相差多少天
func (start Carbon) DiffInDays(end Carbon) int64 <span class="cov8" title="1">{
        return start.DiffInSeconds(end) / SecondsPerDay
}</span>

// DiffInDaysWithAbs 相差多少天（绝对值）
func (start Carbon) DiffInDaysWithAbs(end Carbon) int64 <span class="cov8" title="1">{
        diff := start.DiffInDays(end)
        if diff &lt; 0 </span><span class="cov8" title="1">{
                diff = -diff
        }</span>
        <span class="cov8" title="1">return diff</span>
}

// DiffInHours 相差多少小时
func (start Carbon) DiffInHours(end Carbon) int64 <span class="cov8" title="1">{
        return start.DiffInSeconds(end) / SecondsPerHour
}</span>

// DiffInHoursWithAbs 相差多少小时（绝对值）
func (start Carbon) DiffInHoursWithAbs(end Carbon) int64 <span class="cov8" title="1">{
        diff := start.DiffInHours(end)
        if diff &lt; 0 </span><span class="cov8" title="1">{
                diff = -diff
        }</span>
        <span class="cov8" title="1">return diff</span>
}

// DiffInMinutes 相差多少分钟
func (start Carbon) DiffInMinutes(end Carbon) int64 <span class="cov8" title="1">{
        return start.DiffInSeconds(end) / SecondsPerMinute
}</span>

// DiffInMinutesWithAbs 相差多少分钟（绝对值）
func (start Carbon) DiffInMinutesWithAbs(end Carbon) int64 <span class="cov8" title="1">{
        diff := start.DiffInMinutes(end)
        if diff &lt; 0 </span><span class="cov8" title="1">{
                diff = -diff
        }</span>
        <span class="cov8" title="1">return diff</span>
}

// DiffInSeconds 相差多少秒
func (start Carbon) DiffInSeconds(end Carbon) int64 <span class="cov8" title="1">{
        if start.Time.IsZero() &amp;&amp; end.Time.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">if end.Time.IsZero() </span><span class="cov8" title="1">{
                return -start.ToTimestamp()
        }</span>
        <span class="cov8" title="1">if start.Time.IsZero() </span><span class="cov8" title="1">{
                return end.ToTimestamp()
        }</span>

        <span class="cov8" title="1">return end.ToTimestamp() - start.ToTimestamp()</span>
}

// DiffInSecondsWithAbs 相差多少秒（绝对值）
func (start Carbon) DiffInSecondsWithAbs(end Carbon) int64 <span class="cov8" title="1">{
        diff := start.DiffInSeconds(end)
        if diff &lt; 0 </span><span class="cov8" title="1">{
                diff = -diff
        }</span>
        <span class="cov8" title="1">return diff</span>
}

// DaysInYear 获取本年的总天数
func (c Carbon) DaysInYear() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">days := DaysPerNormalYear
        if c.IsLeapYear() </span><span class="cov8" title="1">{
                days = DaysPerLeapYear
        }</span>
        <span class="cov8" title="1">return days</span>
}

// DaysInMonth 获取本月的总天数
func (c Carbon) DaysInMonth() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.EndOfMonth().Time.In(c.Loc).Day()</span>
}

// MonthOfYear 获取本年的第几月
func (c Carbon) MonthOfYear() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return int(c.Time.In(c.Loc).Month())</span>
}

// DayOfYear 获取本年的第几天
func (c Carbon) DayOfYear() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).YearDay()</span>
}

// DayOfMonth 获取本月的第几天
func (c Carbon) DayOfMonth() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Day()</span>
}

// DayOfWeek 获取本周的第几天
func (c Carbon) DayOfWeek() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return int(c.Time.In(c.Loc).Weekday())</span>
}

// WeekOfYear 获取本年的第几周
func (c Carbon) WeekOfYear() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">_, week := c.Time.In(c.Loc).ISOWeek()
        return week</span>
}

// WeekOfMonth 获取本月的第几周
func (c Carbon) WeekOfMonth() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">day := c.Time.In(c.Loc).Day()
        if day &lt; DaysPerWeek </span><span class="cov8" title="1">{
                return 1
        }</span>
        <span class="cov8" title="1">return day%DaysPerWeek + 1</span>
}

// Timezone 获取时区
func (c Carbon) Timezone() string <span class="cov8" title="1">{
        return c.Loc.String()
}</span>

// Age 获取年龄
func (c Carbon) Age() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">if c.ToTimestamp() &gt; Now().ToTimestamp() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">age := time.Now().Year() - c.Time.In(c.Loc).Year()
        if int(time.Now().Month())*100+time.Now().Day() &lt; int(c.Time.In(c.Loc).Month())*100+c.Time.In(c.Loc).Day() </span><span class="cov8" title="1">{
                age = age - 1
        }</span>
        <span class="cov8" title="1">return age</span>
}

// 获取当前年
func (c Carbon) Year() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Year()</span>
}

// 获取当前季度
func (c Carbon) Quarter() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">month := c.Time.In(c.Loc).Month()
        quarter := 0
        switch </span>{
        case month &gt;= 1 &amp;&amp; month &lt;= 3:<span class="cov8" title="1">
                quarter = 1</span>
        case month &gt;= 4 &amp;&amp; month &lt;= 6:<span class="cov8" title="1">
                quarter = 2</span>
        case month &gt;= 7 &amp;&amp; month &lt;= 9:<span class="cov8" title="1">
                quarter = 3</span>
        case month &gt;= 10 &amp;&amp; month &lt;= 12:<span class="cov8" title="1">
                quarter = 4</span>
        }
        <span class="cov8" title="1">return quarter</span>
}

// 获取当前月
func (c Carbon) Month() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return int(c.Time.In(c.Loc).Month())</span>
}

// 获取当前日
func (c Carbon) Day() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Day()</span>
}

// 获取当前小时
func (c Carbon) Hour() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Hour()</span>
}

// 获取当前分钟数
func (c Carbon) Minute() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Minute()</span>
}

// 获取当前秒数
func (c Carbon) Second() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Second()</span>
}

// 获取当前毫秒数
func (c Carbon) Millisecond() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Nanosecond() / 1e6</span>
}

// 获取当前微秒数
func (c Carbon) Microsecond() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Nanosecond() / 1e9</span>
}

// 获取当前纳秒数
func (c Carbon) Nanosecond() int <span class="cov8" title="1">{
        if c.IsZero() </span><span class="cov8" title="1">{
                return 0
        }</span>
        <span class="cov8" title="1">return c.Time.In(c.Loc).Nanosecond()</span>
}

// IsZero 是否是零值
func (c Carbon) IsZero() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).IsZero()
}</span>

// IsNow 是否是当前时间
func (c Carbon) IsNow() bool <span class="cov8" title="1">{
        return c.ToTimestamp() == c.Now().ToTimestamp()
}</span>

// IsFuture 是否是未来时间
func (c Carbon) IsFuture() bool <span class="cov8" title="1">{
        return c.ToTimestamp() &gt; c.Now().ToTimestamp()
}</span>

// IsPast 是否是过去时间
func (c Carbon) IsPast() bool <span class="cov8" title="1">{
        return c.ToTimestamp() &lt; c.Now().ToTimestamp()
}</span>

// IsLeapYear 是否是闰年
func (c Carbon) IsLeapYear() bool <span class="cov8" title="1">{
        year := c.Time.In(c.Loc).Year()
        if year%400 == 0 || (year%4 == 0 &amp;&amp; year%100 != 0) </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// IsLongYear 是否是长年
func (c Carbon) IsLongYear() bool <span class="cov8" title="1">{
        t := time.Date(c.Year(), time.December, 31, 0, 0, 0, 0, c.Loc)
        _, w := t.ISOWeek()
        return w == weeksPerLongYear
}</span>

// IsJanuary 是否是一月
func (c Carbon) IsJanuary() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.January
}</span>

// IsMonday 是否是二月
func (c Carbon) IsFebruary() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.February
}</span>

// IsMarch 是否是三月
func (c Carbon) IsMarch() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.March
}</span>

// IsApril 是否是四月
func (c Carbon) IsApril() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.April
}</span>

// IsMay 是否是五月
func (c Carbon) IsMay() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.May
}</span>

// IsJune 是否是六月
func (c Carbon) IsJune() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.June
}</span>

// IsJuly 是否是七月
func (c Carbon) IsJuly() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.July
}</span>

// IsAugust 是否是八月
func (c Carbon) IsAugust() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.August
}</span>

// IsSeptember 是否是九月
func (c Carbon) IsSeptember() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.September
}</span>

// IsOctober 是否是十月
func (c Carbon) IsOctober() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.October
}</span>

// IsNovember 是否是十一月
func (c Carbon) IsNovember() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.November
}</span>

// IsDecember 是否是十二月
func (c Carbon) IsDecember() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Month() == time.December
}</span>

// IsMonday 是否是周一
func (c Carbon) IsMonday() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Weekday() == time.Monday
}</span>

// IsTuesday 是否是周二
func (c Carbon) IsTuesday() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Weekday() == time.Tuesday
}</span>

// IsWednesday 是否是周三
func (c Carbon) IsWednesday() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Weekday() == time.Wednesday
}</span>

// IsThursday 是否是周四
func (c Carbon) IsThursday() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Weekday() == time.Thursday
}</span>

// IsFriday 是否是周五
func (c Carbon) IsFriday() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Weekday() == time.Friday
}</span>

// IsSaturday 是否是周六
func (c Carbon) IsSaturday() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Weekday() == time.Saturday
}</span>

// IsSunday 是否是周日
func (c Carbon) IsSunday() bool <span class="cov8" title="1">{
        return c.Time.In(c.Loc).Weekday() == time.Sunday
}</span>

// IsWeekday 是否是工作日
func (c Carbon) IsWeekday() bool <span class="cov8" title="1">{
        return !c.IsSaturday() &amp;&amp; !c.IsSunday()
}</span>

// IsWeekend 是否是周末
func (c Carbon) IsWeekend() bool <span class="cov8" title="1">{
        return c.IsSaturday() || c.IsSunday()
}</span>

// IsYesterday 是否是昨天
func (c Carbon) IsYesterday() bool <span class="cov8" title="1">{
        return c.ToDateString() == Now().SubDay().ToDateString()
}</span>

// IsToday 是否是今天
func (c Carbon) IsToday() bool <span class="cov8" title="1">{
        return c.ToDateString() == c.Now().ToDateString()
}</span>

// IsTomorrow 是否是明天
func (c Carbon) IsTomorrow() bool <span class="cov8" title="1">{
        return c.ToDateString() == Now().AddDay().ToDateString()
}</span>

// Compare 时间比较
func (c Carbon) Compare(operator string, t Carbon) bool <span class="cov8" title="1">{
        switch operator </span>{
        case &quot;=&quot;:<span class="cov8" title="1">
                return c.Time.Equal(t.Time)</span>
        case &quot;&lt;&gt;&quot;:<span class="cov8" title="1">
                return !c.Time.Equal(t.Time)</span>
        case &quot;!=&quot;:<span class="cov8" title="1">
                return !c.Time.Equal(t.Time)</span>
        case &quot;&gt;&quot;:<span class="cov8" title="1">
                return c.Time.After(t.Time)</span>
        case &quot;&gt;=&quot;:<span class="cov8" title="1">
                return c.Time.After(t.Time) || c.Time.Equal(t.Time)</span>
        case &quot;&lt;&quot;:<span class="cov8" title="1">
                return c.Time.Before(t.Time)</span>
        case &quot;&lt;=&quot;:<span class="cov8" title="1">
                return c.Time.Before(t.Time) || c.Time.Equal(t.Time)</span>
        }

        <span class="cov8" title="1">return false</span>
}

// Gt 大于
func (c Carbon) Gt(t Carbon) bool <span class="cov8" title="1">{
        return c.Time.After(t.Time)
}</span>

// Lt 小于
func (c Carbon) Lt(t Carbon) bool <span class="cov8" title="1">{
        return c.Time.Before(t.Time)
}</span>

// Eq 等于
func (c Carbon) Eq(t Carbon) bool <span class="cov8" title="1">{
        return c.Time.Equal(t.Time)
}</span>

// Ne 不等于
func (c Carbon) Ne(t Carbon) bool <span class="cov8" title="1">{
        return !c.Time.Equal(t.Time)
}</span>

// Gte 大于等于
func (c Carbon) Gte(t Carbon) bool <span class="cov8" title="1">{
        return c.Time.After(t.Time) || c.Time.Equal(t.Time)
}</span>

// Lte 小于等于
func (c Carbon) Lte(t Carbon) bool <span class="cov8" title="1">{
        return c.Time.Before(t.Time) || c.Time.Equal(t.Time)
}</span>

// Between 是否在两个时间之间(不包括这两个时间)
func (c Carbon) Between(start Carbon, end Carbon) bool <span class="cov8" title="1">{
        if c.Time.After(start.Time) &amp;&amp; c.Time.Before(end.Time) </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// BetweenIncludedStartTime 是否在两个时间之间(包括开始时间)
func (c Carbon) BetweenIncludedStartTime(start Carbon, end Carbon) bool <span class="cov8" title="1">{
        if (c.Time.After(start.Time) || c.Time.Equal(start.Time)) &amp;&amp; c.Time.Before(end.Time) </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// BetweenIncludedEndTime 是否在两个时间之间(包括结束时间)
func (c Carbon) BetweenIncludedEndTime(start Carbon, end Carbon) bool <span class="cov8" title="1">{
        if c.Time.After(start.Time) &amp;&amp; (c.Time.Before(end.Time) || c.Time.Equal(end.Time)) </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}

// BetweenIncludedBoth 是否在两个时间之间(包括这两个时间)
func (c Carbon) BetweenIncludedBoth(start Carbon, end Carbon) bool <span class="cov8" title="1">{
        if (c.Time.After(start.Time) || c.Time.Equal(start.Time)) &amp;&amp; (c.Time.Before(end.Time) || c.Time.Equal(end.Time)) </span><span class="cov8" title="1">{
                return true
        }</span>
        <span class="cov8" title="1">return false</span>
}
</pre>
        <pre class="file" id="file5" style="display: none">package carbon

import (
        &quot;bytes&quot;
        &quot;errors&quot;
        &quot;time&quot;
)

// 常规格式化符号
var formats = map[byte]string{
        'd': &quot;02&quot;,                        // Day:    Day of the month, 2 digits with leading zeros. Eg: 01 to 31.
        'D': &quot;Mon&quot;,                       // Day:    A textual representation of a day, three letters. Eg: Mon through Sun.
        'j': &quot;2&quot;,                         // Day:    Day of the month without leading zeros. Eg: 1 to 31.
        'l': &quot;Monday&quot;,                    // Day:    A full textual representation of the day of the week. Eg: Sunday through Saturday.
        'F': &quot;January&quot;,                   // Month:  A full textual representation of a month, such as January or March. Eg: January through December.
        'm': &quot;01&quot;,                        // Month:  Numeric representation of a month, with leading zeros. Eg: 01 through 12.
        'M': &quot;Jan&quot;,                       // Month:  A short textual representation of a month, three letters. Eg: Jan through Dec.
        'n': &quot;1&quot;,                         // Month:  Numeric representation of a month, without leading zeros. Eg: 1 through 12.
        'Y': &quot;2006&quot;,                      // Year:   A full numeric representation of a year, 4 digits. Eg: 1999 or 2003.
        'y': &quot;06&quot;,                        // Year:   A two digit representation of a year. Eg: 99 or 03.
        'a': &quot;pm&quot;,                        // Time:   Lowercase Ante meridiem and Post meridiem. Eg: am or pm.
        'A': &quot;PM&quot;,                        // Time:   Uppercase Ante meridiem and Post meridiem. Eg: AM or PM.
        'g': &quot;3&quot;,                         // Time:   12-hour format of an hour without leading zeros. Eg: 1 through 12.
        'h': &quot;03&quot;,                        // Time:   12-hour format of an hour with leading zeros. Eg: 01 through 12.
        'H': &quot;15&quot;,                        // Time:   24-hour format of an hour with leading zeros. Eg: 00 through 23.
        'i': &quot;04&quot;,                        // Time:   Minutes with leading zeros. Eg: 00 to 59.
        's': &quot;05&quot;,                        // Time:   Seconds with leading zeros. Eg: 00 through 59.
        'O': &quot;-0700&quot;,                     // Zone:   Difference to Greenwich time (GMT) in hours. Eg: +0200.
        'P': &quot;-07:00&quot;,                    // Zone:   Difference to Greenwich time (GMT) with colon between hours and minutes. Eg: +02:00.
        'T': &quot;MST&quot;,                       // Zone:   Timezone abbreviation. Eg: UTC, EST, MDT ...
        'c': &quot;2006-01-02T15:04:05-07:00&quot;, // Format: ISO 8601 date. Eg: 2004-02-12T15:19:21+00:00.
        'r': &quot;Mon, 02 Jan 06 15:04 MST&quot;,  // Format: RFC 2822 formatted date. Eg: Thu, 21 Dec 2000 16:01:07 +0200.
}

// format转layout
func format2layout(format string) string <span class="cov8" title="1">{
        runes := []rune(format)
        buffer := bytes.NewBuffer(nil)
        for i := 0; i &lt; len(runes); i++ </span><span class="cov8" title="1">{
                if layout, ok := formats[byte(runes[i])]; ok </span><span class="cov8" title="1">{
                        buffer.WriteString(layout)
                }</span> else<span class="cov8" title="1"> {
                        buffer.WriteRune(runes[i])
                }</span>
        }
        <span class="cov8" title="1">return buffer.String()</span>
}

// getLocationByTimezone 通过时区获取Location实例
func getLocationByTimezone(timezone string) (*time.Location, error) <span class="cov8" title="1">{
        loc, err := time.LoadLocation(timezone)
        if err != nil </span><span class="cov8" title="1">{
                err = errors.New(&quot;invalid timezone \&quot;&quot; + timezone + &quot;\&quot;, please see the $GOROOT/lib/time/zoneinfo.zip file for all valid timezone&quot;)
        }</span>
        <span class="cov8" title="1">return loc, err</span>
}

// parseByLayout 通过布局模板解析
func parseByLayout(value string, layout string) (time.Time, error) <span class="cov8" title="1">{
        loc, _ := time.LoadLocation(Local)
        tt, err := time.ParseInLocation(layout, value, loc)
        if err != nil </span><span class="cov8" title="1">{
                err = errors.New(&quot;the value \&quot;&quot; + value + &quot;\&quot; can't parse string as time&quot;)
        }</span>
        <span class="cov8" title="1">return tt, err</span>
}

// parseByDuration 通过持续时间解析
func parseByDuration(duration string) (time.Duration, error) <span class="cov8" title="1">{
        td, err := time.ParseDuration(duration)
        if err != nil </span><span class="cov8" title="1">{
                err = errors.New(&quot;invalid duration \&quot;&quot; + duration + &quot;\&quot;&quot;)
        }</span>
        <span class="cov8" title="1">return td, err</span>
}
</pre>
</div>
<script>
        (function() {
                var files = document.getElementById('files');
                var visible;
                files.addEventListener('change', onChange, false);
                function select(part) {
                        if (visible)
                                visible.style.display = 'none';
                        visible = document.getElementById(part);
                        if (!visible)
                                return;
                        files.value = part;
                        visible.style.display = 'block';
                        location.hash = part;
                }
                function onChange() {
                        select(files.value);
                        window.scrollTo(0, 0);
                }
                if (location.hash != "") {
                        select(location.hash.substr(1));
                }
                if (!visible) {
                        select("file0");
                }
        })();
</script>
</body>
</html>